package com.ukao.steward.ui.valetRunners.storage;


import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ukao.steward.R;
import com.ukao.steward.adapter.AddClothingAdapter;
import com.ukao.steward.adapter.RemoveClothingAdapter;
import com.ukao.steward.base.MvpFragment;
import com.ukao.steward.bean.AddClothingItem;
import com.ukao.steward.bean.StringBean;
import com.ukao.steward.consts.SaveParams;
import com.ukao.steward.dialog.SelectNumDialogFragment;
import com.ukao.steward.eventbus.AddClothingEvent;
import com.ukao.steward.eventbus.AppEvent;
import com.ukao.steward.listener.DialogSubmitListener;
import com.ukao.steward.pesenter.valetRunners.AddClothingPesenter;
import com.ukao.steward.util.CheckUtils;
import com.ukao.steward.util.DecimalUtil;
import com.ukao.steward.util.KeyBoardUtil;
import com.ukao.steward.util.T;
import com.ukao.steward.view.valetRunners.AddClothingView;

import org.greenrobot.eventbus.Subscribe;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

import static com.ukao.steward.R.id.seach_edit;
import static com.ukao.steward.consts.Constant.ADDITIONAL_SERVICES_EIGHT;
import static com.ukao.steward.consts.Constant.ADJUNCT_THREE;
import static com.ukao.steward.consts.Constant.CLOTHING_ONE;
import static com.ukao.steward.consts.Constant.PROJECT_ZERO;
import static com.ukao.steward.consts.Constant.SERVE_TWO;
import static com.ukao.steward.eventbus.AppEvent.Message.update;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link AddClothingChildFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class AddClothingChildFragment extends MvpFragment<AddClothingPesenter> implements AddClothingView {
    // TODO: Rename parameter arguments, choose names that match
    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";
    @BindView(R.id.remove_recycler)
    RecyclerView removeRecycler;
    @BindView(R.id.all_recycler)
    RecyclerView allRecycler;
    @BindView(R.id.seach_recycler)
    RecyclerView seachRecycler;

    @BindView(R.id.no_data)
    TextView noData;
    @BindView(R.id.seach_layout)
    FrameLayout seachLayout;
    @BindView(R.id.seach_image)
    ImageView seachImage;
    @BindView(R.id.add_layout)
    LinearLayout addLayout;
    @BindView(R.id.add_image)
    ImageView addImage;

    @BindView(R.id.keyboard_layout)
    LinearLayout keyboardLayout;
    @BindView(R.id.add_edit)
    EditText addEdit;
    @BindView(seach_edit)
    EditText seachEdit;



    private String mParam1;
    private String mParam2;
    private List<StringBean> mDesclist;
    private boolean isEnabledSearch;
    private boolean isEnabledAdd;
    private boolean isSinge;
    private boolean isEnabledKeyboard;
    private int enterPos;

    private AddClothingAdapter mAllAdapter;
    private Unbinder unbinder;
    private RemoveClothingAdapter mRemoveAdapter;
    private AddClothingAdapter mSearchAdapter;
    private boolean mHasLoadedOnce;

    private int isCustomNum;
    private String unitText;
    private String selectid;
    private StringBuffer mSearchBuffer;
    private String orderId;

    private String totalServiceDesc;
    private String productId;

    public static Builder createBuilder() {
        return new Builder();
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }


    public static final class Builder {
        private boolean isEnabledSearch;
        private boolean isEnabledAdd;
        private boolean isSinge;
        private boolean isEnabledKeyboard;
        private int enterPos;

        private String orderId = "";
        private  String  selectid;
        private  List<StringBean>    mDesclist;
        private String productId = "";
        private String unitText;
        private int isCustomNum;


        public Builder() {
        }


        public Builder isEnabledSearch(boolean val) {
            isEnabledSearch = val;
            return this;
        }

        public Builder unitText(String var) {
            this.unitText= var;
            return this;
        }
        public Builder isCustomNum(int  var) {
            this.isCustomNum= var;
            return this;
        }
        /**
         * 数据回显示默认选中
         */
        public Builder setDefaultMatchCheck(String selectid) {
            this.selectid = selectid;
            return this;
        }
        /**
         * 数据回显示多选的默认选中
         */
        public Builder setDefaultMoreMatchCheck(List<StringBean> mDesclist) {
            this.mDesclist = mDesclist;
            return this;
        }

        public Builder productId(String var) {
            this.productId = var;
            return this;
        }
        public Builder orderId(String val) {
            orderId = val;
            return this;
        }

        public Builder isEnabledAdd(boolean val) {
            isEnabledAdd = val;
            return this;
        }

        public Builder enterPos(int val) {
            enterPos = val;
            return this;
        }



        public Builder isSinge(boolean val) {
            isSinge = val;
            return this;
        }

        public Builder isEnabledKeyboard(boolean val) {
            isEnabledKeyboard = val;
            return this;
        }

        public AddClothingChildFragment build() {
            return AddClothingChildFragment.newInstance(isEnabledSearch, isEnabledAdd, isSinge, isEnabledKeyboard, enterPos,
                    orderId,selectid,mDesclist,productId,  unitText, isCustomNum);
        }
    }


    public static AddClothingChildFragment newInstance(boolean isEnabledSearch, boolean isEnabledAdd, boolean isSinge, boolean isEnabledKeyboard,
                                                       int enterPos , String orderId,String selectid,List<StringBean> mDesclist
            ,String productId  ,String  unitText,int isCustomNum) {
        AddClothingChildFragment fragment = new AddClothingChildFragment();
        Bundle args = new Bundle();

        args.putBoolean("isEnabledSearch", isEnabledSearch);
        args.putBoolean("isEnabledAdd", isEnabledAdd);
        args.putBoolean("isSinge", isSinge);
        args.putBoolean("isEnabledKeyboard", isEnabledKeyboard);
        args.putInt("enterPos", enterPos);
        args.putString("selectid", selectid);
        args.putString("orderId", orderId);
        args.putString("productId", productId);
        args.putString("unitText", unitText);
        args.putInt("isCustomNum", isCustomNum);
        args.putParcelableArrayList("mDesclist", (ArrayList) mDesclist);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {

            isEnabledSearch = getArguments().getBoolean("isEnabledSearch");
            isEnabledAdd = getArguments().getBoolean("isEnabledAdd");
            isSinge = getArguments().getBoolean("isSinge");
            isEnabledKeyboard = getArguments().getBoolean("isEnabledKeyboard");
            enterPos = getArguments().getInt("enterPos");
            selectid = getArguments().getString("selectid");
            orderId = getArguments().getString("orderId");
            mDesclist = getArguments().getParcelableArrayList("mDesclist");
            productId = getArguments().getString("productId");
            unitText = getArguments().getString("unitText");
            isCustomNum = getArguments().getInt("isCustomNum",0);

        }
    }

    @Override
    protected AddClothingPesenter createPresenter() {
        return new AddClothingPesenter(this);
    }

    @Override
    protected void initView() {
        keyboardLayout.setVisibility(isEnabledKeyboard ? View.VISIBLE : View.GONE);
         addLayout.setVisibility(isEnabledAdd&&!isEnabledKeyboard? View.VISIBLE:View.GONE );
        seachImage.setVisibility(!isEnabledSearch ? View.GONE : View.VISIBLE);
        addImage.setVisibility(!isEnabledAdd? View.GONE : View.VISIBLE);

        initAdapter();

    }


    private void initAdapter() {
        List mAllData = new ArrayList<>();
        initGridRecyclerView(allRecycler, 4);
        mAllAdapter = new AddClothingAdapter(_mActivity, mAllData);
        allRecycler.setAdapter(mAllAdapter);
        if (isEnabledKeyboard) {
            mSearchBuffer= new StringBuffer();
            initGridRecyclerView(seachRecycler, 4);
            mSearchAdapter = new AddClothingAdapter(_mActivity, mAllData);
            seachRecycler.setAdapter(mSearchAdapter);
        }
        if (!isSinge) {
            List mRemoveData = new ArrayList<>();
            initGridRecyclerView(removeRecycler, 4);
            mRemoveAdapter = new RemoveClothingAdapter(_mActivity, mRemoveData);
            removeRecycler.setAdapter(mRemoveAdapter);
        }

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_add_clothing_child, container, false);
        unbinder = ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

    }

    @Override
    protected void initListener() {
        super.initListener();

        mAllAdapter.setOnItemClickListener(position -> {
            AddClothingItem mAddClothingItem = mAllAdapter.getItem(position);
            clothingSelectEven(position, mAddClothingItem);

        });
        if (mRemoveAdapter != null) {
            mRemoveAdapter.setOnItemClickListener(position -> {
                AddClothingItem mItem = mRemoveAdapter.getItem(position);
                if (mItem == null) return;
                List<AddClothingItem> mAllData = mAllAdapter.getDataList();
                if (mAllData.contains(mItem)) {
                    int index = mAllData.indexOf(mItem);
                    if (index != -1) {
                        mAllData.get(index).setCheck(false);
                    }
                    mRemoveAdapter.getDataList().remove(mItem);
                    if (mRemoveAdapter.getDataList().size() == 0)
                        removeRecycler.setVisibility(View.GONE);
                        sendData(mItem);



                }


            });
        }
        if (mSearchAdapter != null) {
            mSearchAdapter.setOnItemClickListener(position -> {
                AddClothingItem mAddClothingItem = mSearchAdapter.getItem(position);
                if (mAddClothingItem != null) {
                    int indexOf = mAllAdapter.getDataList().indexOf(mAddClothingItem);
                    if (indexOf != -1) {
                        clothingSelectEven(indexOf, mAllAdapter.getDataList().get(indexOf));


                    }

                }


            });
        }

    }

    private void clothingSelectEven(int position, AddClothingItem mAddClothingItem) {
        if (mAddClothingItem != null) {
            if (isCustomNum == 1) {
                SelectNumDialogFragment.
                        createBuilder(getFragmentManager()).
                        setmDialogTitle("服务:" + mAddClothingItem.getName()).
                        setUnitPice("单价：" + mAddClothingItem.getPrice() + "元/" + unitText)
                        .setUnitTitle(unitText)
                        .setListener((DialogSubmitListener) (parent, message) -> {
                            setDialogEvent(position,(String) message);
                        }).show();

            } else if (enterPos == ADDITIONAL_SERVICES_EIGHT) {
                SelectNumDialogFragment
                        .createBuilder(getFragmentManager())
                        .setmDialogTitle("附加服务:" + mAddClothingItem.getName())
                        .setUnitTitle("元")
                        .setListener((DialogSubmitListener) (parent, message) -> {
                            setDialogEvent(position,(String) message);
                        }).show();


            } else {
                if (enterPos == SERVE_TWO) {
                    mAddClothingItem.setUnitText(unitText);
                    mAddClothingItem.setCount("1");
                    String unitPrice = "单价：" + mAddClothingItem.getPrice() + "元/" + unitText;
                    mAddClothingItem.setUnitpice(unitPrice);
                    mAddClothingItem.setUnitText(unitText);
                }
                notifyDataSetPage(position, mAddClothingItem);
            }

        }
    }

    /**
     * 弹框回调事件
     * @param position
     * @param count
     */
    private  void  setDialogEvent(int position ,String  count){
        AddClothingItem    item =mAllAdapter.getDataList().get(position);
        if (enterPos == SERVE_TWO) {/*服务*/
            String  unitPrice = "";
            item.setCount(count);
            unitPrice = "单价：" + item.getPrice() + "元/" + unitText;
            item.setUnitpice(unitPrice);
            item.setUnitText(unitText);

        } else {
            item.setUnitText("元");
            item.setCount(count);


        }
        notifyDataSetPage(position, item);
    }

    private void addDesc(JSONArray mJSONArray, AddClothingItem addClothingItem) {
        try {
            JSONObject mJSONObject = new JSONObject();
            mJSONObject.put("id", addClothingItem.getId());
            mJSONObject.put("name", addClothingItem.getName());
            if (enterPos == ADDITIONAL_SERVICES_EIGHT) {/*附加得添加金额*/
                String count = addClothingItem.getCount();
                mJSONObject.put("amt", DecimalUtil.multiply(count));
                totalServiceDesc = DecimalUtil.add(totalServiceDesc, count);
            }
            mJSONArray.put(mJSONObject);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    private void notifyDataSetPage(int position, AddClothingItem item) {


        if (isSinge) {  /*单选模式*/
            if (item.isCheck()&&isCustomNum!=1) {
                return;
            }
            for (int i = 0; i < mAllAdapter.getDataList().size(); i++) {
                    if (position!=i){
                         mAllAdapter.getDataList().get(i).setCheck(false);
                    }

            }
            item.setCheck(true);
            item.setEnterPos(enterPos);
            item.setSinge(isSinge);

        } else {    /*多选模式*/
            if(item.isCheck()&&enterPos == ADDITIONAL_SERVICES_EIGHT){
            }else {
                List<AddClothingItem> mRemoveData = mRemoveAdapter.getDataList();
                item.setCheck(!item.isCheck());
                if (item.isCheck()) {
                    if (!mRemoveData.contains(item)) {
                        item.setPosition(position);
                        mRemoveData.add(item);
                    }

                    if (mRemoveData.size() > 0) removeRecycler.setVisibility(View.VISIBLE);


                } else {
                    if (mRemoveData.contains(item)) mRemoveData.remove(item);
                    if (mRemoveData.size() == 0) removeRecycler.setVisibility(View.GONE);


                }


            }


        }
        sendData(item);



    }

    /**
     * 发送数据
     *
     * @param item
     */
    private void sendData(AddClothingItem item) {

        if (isSinge) {
            AppEvent.postHasData(AppEvent.Message.update, item);
        } else {


            JSONArray mJSONArray = new JSONArray();

            for (AddClothingItem addClothingItem : mRemoveAdapter.getDataList()) {
                addDesc(mJSONArray, addClothingItem);
            }
            AddClothingItem moreitem = new AddClothingItem();
            moreitem.setSelectDesc(mJSONArray.length() == 0 ? "" : mJSONArray.toString());/*附件*/
            moreitem.setEnterPos(enterPos);
            moreitem.setSinge(isSinge);
            AppEvent.postHasData(update, moreitem);
            mRemoveAdapter.notifyDataSetChanged();
        }
        if (mSearchAdapter != null) mSearchAdapter.notifyDataSetChanged();
        mAllAdapter.notifyDataSetChanged();
    }



    @Override
    public void onSupportVisible() {
        super.onSupportVisible();
        if (mHasLoadedOnce){

            return;
        }
        if (!CheckUtils.isNull(mRemoveAdapter) && mRemoveAdapter.getDataList().size() != 0)
            mRemoveAdapter.clear();
        requestData();
    }

    public void setProductId(String productId, boolean mHasLoadedOnce) {
        this.productId = productId;
        if (enterPos != PROJECT_ZERO)
            this.mHasLoadedOnce = mHasLoadedOnce;
    }

    public void setProductIdUnit(String productId, int isCustomNum, String unitText, boolean mHasLoadedOnce, String proServiceId) {

        this.isCustomNum = isCustomNum; /*如果是1就弹对话框*/
        this.productId = productId; /*项目id*/
        this.unitText = unitText; /*单位*/
        this.mHasLoadedOnce = mHasLoadedOnce;
        this.selectid = proServiceId;/*服务回显示id */

    }



    private void requestData() {
        HashMap mHashMap = new HashMap<String, String>();
        switch (enterPos) {
            case PROJECT_ZERO:
                mHashMap.put("accessToken", SaveParams.getToken());
                mvpPresenter.projectData(mHashMap, enterPos);
                break;
            case CLOTHING_ONE:
                mHashMap.put("orderId", orderId);
                mHashMap.put("mercBusinessId", productId);
                mHashMap.put("accessToken", SaveParams.getToken());
                mvpPresenter.projectData(mHashMap, enterPos);
                break;
            case SERVE_TWO:
                mHashMap.put("orderId", orderId);
                mHashMap.put("productId", productId);
                mHashMap.put("accessToken", SaveParams.getToken());
                mvpPresenter.projectData(mHashMap, enterPos);

                break;
            case ADJUNCT_THREE:

                mHashMap.put("businessId", productId);
                mHashMap.put("accessToken", SaveParams.getToken());
                mvpPresenter.projectData(mHashMap, enterPos);
                break;
            case ADDITIONAL_SERVICES_EIGHT:
                mHashMap.put("businessId", productId);
                mHashMap.put("accessToken", SaveParams.getToken());
                mvpPresenter.projectData(mHashMap, enterPos);
                break;
        }
        if (ADJUNCT_THREE < enterPos && enterPos < ADDITIONAL_SERVICES_EIGHT) {
            mHashMap.put("accessToken", SaveParams.getToken());
            mvpPresenter.projectData(mHashMap, enterPos);
        }
    }

    @Override
    public void onSupportInvisible() {
        super.onSupportInvisible();
        if (mHasLoadedOnce && mSearchAdapter != null && mSearchAdapter.getDataList() != null && mAllAdapter.getDataList().size() != 0) {
            if (mSearchAdapter.getDataList().size() != mAllAdapter.getDataList().size())
                mSearchAdapter.setDataList(mAllAdapter.getDataList());
            mSearchAdapter.notifyDataSetChanged();
            seachEdit.setText("");
            noData.setVisibility(View.GONE);
            if (mSearchBuffer != null)
                mSearchBuffer.setLength(0);
        }

    }

    @Override
    public void getProjectSuccess(List<AddClothingItem> model) {
        mHasLoadedOnce = true;
        mAllAdapter.setDataList(model);
        if (mSearchAdapter != null) mSearchAdapter.setDataList(model);
        if (!CheckUtils.isEmpty(selectid)) {

            for (int i = 0; i < mAllAdapter.getDataList().size(); i++) {
                AddClothingItem item = mAllAdapter.getDataList().get(i);
                if (enterPos==0&&selectid.equals(item.getBusinessId())){
                    item.setCheck(true);
                }else if (selectid.equals(item.getId())) {
                    item.setCheck(true);
                }


            }
            mAllAdapter.notifyDataSetChanged();
        } else if (!CheckUtils.isEmpty(mDesclist)) {
            for (int i = 0; i < mAllAdapter.getDataList().size(); i++) {
                AddClothingItem mitem = mAllAdapter.getDataList().get(i);
                String strId = mitem.getId();

                for (int j = 0; j < mDesclist.size(); j++) {
                    if (strId.equals(mDesclist.get(j).getId())) {
                        if (enterPos == ADDITIONAL_SERVICES_EIGHT) {
                            mitem.setCount(CheckUtils.isEmptyNumber(mDesclist.get(j).getAmt()));
                            mitem.setUnitText("元");
                        }
                        mitem.setPosition(i);
                        mitem.setCheck(true);
                        if (mRemoveAdapter != null)
                            mRemoveAdapter.getDataList().add(mitem);


                    }
                }

            }
            mAllAdapter.notifyDataSetChanged();
            if (mRemoveAdapter != null && !CheckUtils.isEmpty(mRemoveAdapter.getDataList())) {
                mRemoveAdapter.notifyDataSetChanged();
                removeRecycler.setVisibility(View.VISIBLE);
            }


        }

    }

    @Override
    public void loadFail(String message) {
        T.show(message);
        mHasLoadedOnce = false;
    }
    Handler mHandler = new Handler();
    @OnClick({R.id.add_btn, R.id.seach_image, R.id.add_image, R.id.Button1,
            R.id.Button2, R.id.Button3, R.id.Button4, R.id.Button5, R.id.Button6, R.id.Button7,
            R.id.Button8, R.id.Button9, R.id.Button10, R.id.Button11, R.id.Button12, R.id.Button13,
            R.id.Button14, R.id.Button15, R.id.Button16, R.id.Button17, R.id.Button18, R.id.Button19,
            R.id.Button20, R.id.Button21, R.id.Button22, R.id.Button23, R.id.Button24, R.id.Button25, R.id.Button26, R.id.Button27})
    public void onViewClicked(View view) {
        int i = view.getId();
        switch (i) {
            case R.id.seach_image:
                setVisibilityState(View.VISIBLE, View.GONE);
                KeyBoardUtil.hideInputmethod(addEdit);

                break;
            case R.id.add_image:
                setVisibilityState(View.GONE, View.VISIBLE);
                KeyBoardUtil.showKeyboard(addEdit);
                break;
            case R.id.add_btn:
                String addtag = getText(addEdit);
                if (addtag.isEmpty()) return;
                hideSoftInput();
                AddClothingItem mDataBean = new AddClothingItem();
                mDataBean.setName(addtag);
                mDataBean.setId("");
                addEdit.setText("");
                mAllAdapter.getDataList().add(0, mDataBean);
                clothingSelectEven(0, mDataBean);

                break;
            case R.id.Button27:
                if (mHasLoadedOnce&&allRecycler.getVisibility()==View.GONE){
                    seachLayout.setVisibility(View.GONE);
                    allRecycler.setVisibility(View.VISIBLE);
                    mSearchAdapter.setDataList(mAllAdapter.getDataList());
                    mSearchAdapter.notifyDataSetChanged();
                    noData.setVisibility(View.GONE);
                }
                if (mSearchBuffer.length()!=0){
                    mSearchBuffer.setLength(0);
                    seachEdit.setText("");
                }

                break;
            default:
                Button mButton = (Button) view;
                String s = mButton.getText().toString().trim();
                mSearchBuffer.append(s);
                allRecycler.setVisibility(View.GONE);
                seachLayout.setVisibility(View.VISIBLE);
                seachEdit.setText(mSearchBuffer.toString());
                mHandler.removeCallbacksAndMessages(null);
                mHandler.postDelayed(() -> {
                    String searchContext = getText(seachEdit);
                    if (searchContext.isEmpty()) return;
                    mSearchAdapter.getDataList().clear();
                    for (AddClothingItem mItem : mAllAdapter.getDataList()) {
                        if (mItem.getFirstWord().contains(searchContext)) {
                            mSearchAdapter.getDataList().add(mItem);
                        }
                    }
                    if (mSearchAdapter.getDataList().size() == 0) {

                        noData.setVisibility(View.VISIBLE);

                    } else {

                        noData.setVisibility(View.GONE);
                    }
                    mSearchAdapter.notifyDataSetChanged();

                }, 1000);


                break;
        }
    }

 private    void setVisibilityState(int gone, int visible) {
        keyboardLayout.setVisibility(gone);
        addLayout.setVisibility(visible);
        allRecycler.setVisibility(visible);
       seachLayout.setVisibility(gone);
    }


    @Override
    protected boolean useEventBus() {
        return true;
    }
    @Subscribe
    public void onEvent(AddClothingEvent event) {
        switch (event.getMessage()) {
            case unselect:
           boolean     isSelectClothing=(boolean)event.getData();
                if (enterPos != 0) {
                    selectid = null;
                    mDesclist = null;
                }

                if (CheckUtils.isEmpty(mAllAdapter.getDataList()) || enterPos == 0) return;
                if (enterPos == SERVE_TWO&&!isSelectClothing|| enterPos == ADJUNCT_THREE || enterPos == ADDITIONAL_SERVICES_EIGHT) {  /*服务于 附件 和附加都要清楚数据*/
                        mHasLoadedOnce = false;
                        mAllAdapter.getDataList().clear();
                        mAllAdapter.notifyDataSetChanged();

                } else if (!isSelectClothing){
                    for (AddClothingItem addClothingItem : mAllAdapter.getDataList()) {
                        addClothingItem.setCheck(false);
                    }
                    mAllAdapter.notifyDataSetChanged();
                }
                if (!CheckUtils.isNull(mRemoveAdapter) && !isSinge) {
                    mRemoveAdapter.getDataList().clear();
                    mRemoveAdapter.notifyDataSetChanged();
                    removeRecycler.setVisibility(View.GONE);
                }
                if (mSearchAdapter!=null){
                    mSearchAdapter.notifyDataSetChanged();
                }
                break;
        }

    }

}
